﻿using System;
using ShureValidation.Language;

namespace ShureValidation.Rules
{
    /// <summary>
    /// Base interface for all rules.
    /// </summary>
    /// <remarks>
    /// Rules are used to validate data.
    /// </remarks>
    public interface IRule
    {
        /// <summary>
        /// Format an error message
        /// </summary>
        /// <param name="fieldName">Field (have already been translated)</param>
        /// <param name="rulesLanguage">Language prompts for validation rules.</param>
        /// <returns>Error message formatted for the current language.</returns>
        string Format(string fieldName, IModelLanguage rulesLanguage);

        /// <summary>
        /// Checks if this rule support values of the specified format.
        /// </summary>
        /// <param name="type">Type of value</param>
        /// <returns><c>true</c> if the specified type can be validated; otherwise <c>false</c>.</returns>
        bool SupportsType(Type type);

        /// <summary>
        /// Validate a field value
        /// </summary>
        /// <param name="value">Value to validate</param>
        /// <returns><c>true</c> if validation was successful; otherwise <c>false</c>.</returns>
        bool Validate(object value);
    }
}